package oop01;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/16 22:48
 * @description 异常类
 */
public class TryException extends Exception {

    public static void main(String[] args) {

        // 捕获异常
       /* try {
            System.out.println(10 / 0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.out.println("一般使用来关闭io流异常");

        }*/

        System.out.println(new TryException().div(1, 0));

    }

    /**
     * 抛出异常,处理不了就抛出异常
     *
     * @param a 参数a
     * @param b 参数b
     * @return 异常或int
     */
    private int div(int a, int b) {
        if (b == 0) {
            throw new ArithmeticException();
        }
        return a / b;
    }
}
